/**
 * 基于虚拟DOM的调用函数
 */

import { createVNode, render } from 'vue'

import XtxMessage from './index.vue'

/**
  *
  * @param {*}{ type, text, time }
  */
export function message ({ type, text, time = 2000 }) {
  // XtxMessage自定义组件
  const Message = createVNode(XtxMessage, { type, text })
  // console.log(Message)

  render(Message, document.body)

  Message.component.setupState.show = true
  setTimeout(() => {
    Message.component.setupState.show = false
  }, time)
}
